Skip to content

[Feature] Add Image and variable-shape ImageBatch core types#151

Open
zacharyvincze wants to merge 16 commits into
ROCm:developfrom
zacharyvincze:zv/feature/imagebatchvarshape
Open

[Feature] Add Image and variable-shape ImageBatch core types#151
zacharyvincze wants to merge 16 commits into
ROCm:developfrom
zacharyvincze:zv/feature/imagebatchvarshape

Conversation

@zacharyvincze
Copy link
Copy Markdown
Contributor

This PR introduces foundational types for variable-shape image batches.

New core types (include/core/, src/core/):

  • Image / ImageStorage — single-image handle and backing storage
  • ImageData / ImageBuffer — descriptor + raw buffer for a single image
  • ImageBatchData / ImageBatchBuffer — descriptors for batches of heterogeneous images
  • ImageBatchVarShape — user-facing variable-shape batch container

Supporting changes:

  • Minor ImageFormat tweaks
  • New test helpers in image_test_helpers.hpp and a small addition to test_helpers.hpp

Tests (tests/roccv/cpp/src/tests/core/image/): ~1,250 lines covering Image, ImageData, ImageBatchData, and ImageBatchVarShape.

Next Steps:

  • Update kernel visible wrappers to support per-image metadata indexing, as this will be required when dealing with batches of variable-sized images.
  • Implement Resize operator with variable-sized image batch support. This is the lowest cost, highest usage operator since it allows the user to work with variable sized images -> resize to constant sized tensor -> perform remaining operators while existing operators lack variable-sized image batch support.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds foundational C++ core types for representing single images and variable-shape (heterogeneous) image batches, along with a comprehensive new test suite to validate ownership, casting, and export/snapshot behavior.

Changes:

  • Introduces new core runtime types: Image/ImageStorage, ImageData*, ImageBatchData*, and producer container ImageBatchVarShape.
  • Extends ImageFormat to have a constexpr default representing FMT_NONE and adds equality operators.
  • Adds new C++ tests and test helpers for image and variable-shape batch behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/roccv/cpp/src/tests/core/image/test_image.cpp New unit tests for Image requirements, allocation, lifecycle, export, and wrapping.
tests/roccv/cpp/src/tests/core/image/test_image_data.cpp New unit tests for ImageData strided variants and runtime cast behavior.
tests/roccv/cpp/src/tests/core/image/test_image_batch_var_shape.cpp New unit tests for ImageBatchVarShape push/pop/clear/export/move/iteration behavior.
tests/roccv/cpp/src/tests/core/image/test_image_batch_data.cpp New unit tests for ImageBatchData varshape descriptors and cast behavior.
tests/roccv/cpp/include/test_helpers.hpp Adds AsInt/AsAddr/AsSize helpers for safer EXPECT_EQ comparisons.
tests/roccv/cpp/include/image_test_helpers.hpp Adds fake image/buffer builders and a counting allocator for tests.
src/core/image.cpp Implements Image allocation, requirements calculation, export, and wrapping.
src/core/image_data.cpp Implements ImageData/ImageDataStrided* accessors and buffer-kind tagging.
src/core/image_batch_var_shape.cpp Implements ImageBatchVarShape storage, lazy sync, caching, and export.
src/core/image_batch_data.cpp Implements ImageBatchData/varshape accessors and buffer-kind tagging.
include/core/image.hpp Declares the Image handle type, requirements, and ImageWrapData.
include/core/image_storage.hpp Declares refcounted storage holder for Image buffers.
include/core/image_format.hpp Makes default ImageFormat represent FMT_NONE; adds ==/!=.
include/core/image_data.hpp Declares ImageData hierarchy, buffer-kind enum, and cast mechanism.
include/core/image_buffer.hpp Declares plane/strided buffer descriptors and ImageBuffer aggregate.
include/core/image_batch_var_shape.hpp Declares producer-side variable-shape batch container and export APIs.
include/core/image_batch_data.hpp Declares ImageBatchData hierarchy, buffer-kind enum, and accessors.
include/core/image_batch_buffer.hpp Declares varshape batch descriptor buffer layout (ImageBatchVarShapeBufferStrided).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/image.cpp
Comment thread src/core/image.cpp
Comment thread src/core/image.cpp Outdated
Comment thread src/core/image_batch_var_shape.cpp Outdated
Comment thread include/core/image_batch_var_shape.hpp
Comment thread include/core/image_batch_var_shape.hpp Outdated
Comment thread tests/roccv/cpp/include/image_test_helpers.hpp Outdated
Comment thread tests/roccv/cpp/src/tests/core/image/test_image.cpp Outdated
Comment thread tests/roccv/cpp/include/test_helpers.hpp Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.49754% with 67 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/detail/var_shape_descriptor_table.cpp 81.32% 8 Missing and 9 partials ⚠️
src/core/image_batch_var_shape.cpp 85.47% 10 Missing and 7 partials ⚠️
src/core/image.cpp 84.71% 8 Missing and 5 partials ⚠️
include/core/image_batch_var_shape.hpp 0.00% 6 Missing ⚠️
include/core/image.hpp 28.57% 5 Missing ⚠️
include/core/image_data.hpp 55.56% 3 Missing and 1 partial ⚠️
include/core/image_format.hpp 40.00% 3 Missing ⚠️
include/core/detail/var_shape_descriptor_table.hpp 66.67% 1 Missing ⚠️
include/core/image_batch_data.hpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #151      +/-   ##
===========================================
+ Coverage    78.13%   78.81%   +0.68%     
===========================================
  Files           79       90      +11     
  Lines         3347     3752     +405     
  Branches       733      790      +57     
===========================================
+ Hits          2615     2957     +342     
- Misses         369      411      +42     
- Partials       363      384      +21     
Files with missing lines Coverage Δ
include/core/image_storage.hpp 100.00% <100.00%> (ø)
src/core/image_batch_data.cpp 100.00% <100.00%> (ø)
src/core/image_data.cpp 100.00% <100.00%> (ø)
include/core/detail/var_shape_descriptor_table.hpp 66.67% <66.67%> (ø)
include/core/image_batch_data.hpp 0.00% <0.00%> (ø)
include/core/image_format.hpp 33.33% <40.00%> (+33.33%) ⬆️
include/core/image_data.hpp 55.56% <55.56%> (ø)
include/core/image.hpp 28.57% <28.57%> (ø)
include/core/image_batch_var_shape.hpp 0.00% <0.00%> (ø)
src/core/image.cpp 84.71% <84.71%> (ø)
... and 2 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:precheckin enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants